package com.zyd.controller.result;

import com.zyd.constant.MessageConstant;

import java.io.Serializable;

/**
 * 封装返回结果
 */
public class Result implements Serializable{
    private boolean flag; // 执行结果，true为执行成功 false为执行失败
    private String message; // 返回结果信息
    private Object data; // 返回数据

    public Result(boolean flag, String message) {
        this.flag = flag;
        this.message = message;
    }

    public Result(boolean flag, String message, Object data) {
        this.flag = flag;
        this.message = message;
        this.data = data;
    }

    // 成功的静态方法
    public static Result success() {
        return new Result(true, MessageConstant.QUERY_CHECKITEM_SUCCESS);
    }

    public static Result success(String message) {
        return new Result(true, message);
    }

    public static Result success(Object data) {
        return new Result(true, MessageConstant.QUERY_CHECKITEM_SUCCESS, data);
    }

    public static Result success(String message, Object data) {
        return new Result(true, message, data);
    }

    // 失败的静态方法
    public static Result error(String message) {
        return new Result(false, message);
    }

    public boolean isFlag() {
        return flag;
    }
    public void setFlag(boolean flag) {
        this.flag = flag;
    }
    public String getMessage() {
        return message;
    }
    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }


}
